<!doctype html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>运营人员登录</title>


    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- 自定义css -->
    <link href="css/RtLogin.css" rel="stylesheet">

</head>

<body class="text-center">



    <form class="form-signin">
        <!--登录成功/失败信息提示框-->
        <div id="info" class="alert alert-danger text-center" style="visibility: hidden;">用户名或密码错误</div>

        <h1 class="h3 mb-3 font-weight-normal">运营人员登录</h1>

        <label for="username" class="sr-only">用户名</label>
        <input type="text" id="username" class="form-control" placeholder="用户名" required autofocus>

        <label for="pwd" class="sr-only">密码</label>
        <input type="password" id="pwd" class="form-control" placeholder="密码" required>

        <div class="checkbox mb-3">
            <label>
                <input type="checkbox"> 记住我
            </label>
        </div>

        <button class="btn btn-lg btn-primary btn-block" type="submit">登 录</button>

        <p class="mt-5 mb-3 text-muted">&copy; 成信大培训中心 2020-2021</p>

    </form>


</body>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/bootstrap.min.js"></script>

<!-- 自定义 js -->
<script src="js/OCP.js"></script>
<script>
    //登录判断函数
    $(function () {
        $("form").submit(function () {
            event.preventDefault();
            var page = "http://127.0.0.1/ocp_dev/optLogin";
            var username = $("#username").val();
            var pwd = $("#pwd").val();

            $.post(
                page,
                { "oplog_user_name": username, "oplog_password": pwd },
                function (data) {
                    if (data.code == 1) {
                        $("#info").css("visibility", "visible");
                        $("#info").removeClass("alert-danger");
                        $("#info").addClass("alert alert-success");
                        $("#info").html("登录成功");
                        //设置cookie
                        setCookie("op_username", username);
                        //登录成功 2s 后跳转
                        setTimeout(function () { window.location.replace("OptHome.html") }, 1500);

                    } else {
                        $("#info").css("visibility", "visible");
                        $("#info").addClass("alert alert-danger");
                        $("#info").html("用户名或密码错误");
                        setTimeout(function () { $("#info").css("visibility", "hidden"); }, 1500);
                    }
                }
            );
        });
    });

</script>

</html>